<template>
  <div class="container">
    <!-- 面包屑导航 -->
    <div class="breadcrumb">
      <el-breadcrumb separator="">
        <el-breadcrumb-item
          ><div class="div1">网站信息管理</div></el-breadcrumb-item
        >
        <el-breadcrumb-item
          :to="{ path: '/jcGuide' }"
          v-if="name == 'guide'"
          ><div class="div3">渠道客户导入</div></el-breadcrumb-item
        >
        <el-breadcrumb-item :to="{ path: '/unabsorbed' }" v-if="name == 'unab'"
          ><div class="div3">未分配客户</div></el-breadcrumb-item
        >
        <el-breadcrumb-item
          :to="{ path: '/AssignedCustomers' }"
          v-if="name == 'assign'"
          ><div class="div3">已分配客户</div></el-breadcrumb-item
        >
        <el-breadcrumb-item
          ><div class="div2">订单查看</div></el-breadcrumb-item
        >
      </el-breadcrumb>
    </div>
    <!-- 面包屑导航 -->
    <div class="address">
      <p class="header">查看订单资料</p>
      <div class="box" v-for="items in detail" :key="items.id">
        <p>姓名: {{ items.orderUser.customerName }}</p>
        <p>电话: {{ items.orderUser.customerPhone }}</p>
        <p>地区: {{ items.orderUser.address }}</p>
        <p>资源时间: {{ items.orderUser.createdTime }}</p>
        <div class="goods">
          <span style="color: red">商品:</span>
          <div
            v-for="goodsItems in items.orderCommodityList"
            :key="goodsItems.id"
          >
            {{ goodsItems.name }} {{ goodsItems.number }} * ￥{{
              goodsItems.price
            }}
            = {{ goodsItems.total }} (元)
          </div>
        </div>

        <div class="goods">
          <span style="color: red">附属品:</span>
          <div
            v-for="goodsItems in items.orderComplimentaryList"
            :key="goodsItems.id"
          >
            {{ goodsItems.complimentaryName }} {{ goodsItems.number }} * ￥{{
              goodsItems.price
            }}
            = {{ goodsItems.total }} (元)
          </div>
        </div>

        <p>产品数量:{{ items.orderUser.pieceNumber }}</p>
        <p>订单状态: {{ items.orderUser.orderType }}</p>
        <!-- <p>来源: {{ detail.sourceFrom }}</p> -->
        <p v-if="items.orderUser.comment">留言:{{ items.orderUser.remark }}</p>
        <p v-else>留言:无</p>
      </div>
      <!-- <div class="select">
        <span>分配给: </span>
        <p>
          <el-select v-model="userDitch" placeholder="选择渠道" filterable>
            <el-option
              v-for="items in line"
              :key="items.id"
              :label="items.name"
              :value="items.id"
            ></el-option>
          </el-select>
        </p>
        <p> -->
      <!-- v-if='detail.isAddCustomer=="N"' -->
      <!-- v-if="detail.isAddCustomer == 'N'" -->
      <!-- <el-select
            v-model="customerUserId"
            placeholder="选择客服"
            filterable
          >
            <el-option
              v-for="items in customer"
              :key="items.id"
              :label="items.reallyName"
              :value="items.id"
            ></el-option>
          </el-select> -->
      <!-- <el-select
            v-model="customerUserId"
            placeholder="选择客服"
            filterable
          >
            <el-option
              v-for="items in customer"
              :key="items.id"
              :label="items.reallyName"
              :value="items.id"
            ></el-option>
          </el-select>
        </p> -->
      <!-- 1 已分配 	2 未分配 -->
      <!-- <p>
          <el-button
            type="primary"
            @click="distribution"
            v-if="detail.assignStatus != 1 && parArray.indexOf('qdfp') != -1"
            >确定分配</el-button
          >
          <el-button type="primary" v-if="detail.assignStatus == 1" disabled
            >已分配</el-button
          >
        </p> -->
      <!-- </div> -->
    </div>
    <!-- 订单商品 -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      id: "",
      detail: "",
      userDitch: "",
      customerUserId: "",
      line: [],
      customer: [],
      name: "",
      limits: "",
      parArray: [],
    };
  },
  created() {
    this.id = this.$route.query.id;
    this.name = this.$route.query.name;
    this.detailAxios();
  },
  methods: {
    detailAxios() {
      this.axios
        .get("/order/wsCustomerChannelUser/checkOrder?id=" + this.id)
        .then((res) => {
          if (res.code == 0) {
            this.detail = res.data;
            this.userDitch = res.data.userDitch;
            this.customerUserId = res.data.customerUserId;
          } else {
            this.$message.error(res.message);
          }
        });
    },
    //*** 渠道&&客服数据列表 ***//
    channelAxios() {
      this.axios
        .get(
          "/order/comm/customeruser/selectCustomerditch?salesAuthorityId=2",
          {
            headers: {
              isLoading: false,
            },
          }
        )
        .then((res) => {
          // console.log(res)
          if (res.code == 0) {
            this.line = res.data;
          } else {
            this.$message.error(res.message);
          }
        });
    },
    // 客户下拉框数据
    customerlist() {
      this.axios
        .get("/sys/v1/user/employee/by/sales/authority?salesAuthorityId=2", {
          headers: {
            isLoading: false,
          },
        })
        .then((res) => {
        //   console.log(res);
          if (res.code == 0) {
            this.customer = res.data;
          } else {
            this.$message.error(res.message);
          }
        });
    },
    //*** 渠道&客服数据列表 ***//
    /***分配客户***/
    distribution: _.debounce(function () {
      this.axios
        .post(
          "/order/v1/customer/channel/assign",
          {
            request: {
              channel: this.userDitch,
              customerServiceId: this.customerUserId,
              id: this.id,
              isAddCustomer: this.detail.isAddCustomer,
            },
            version: "",
          },
          {
            headers: {
              isLoading: false,
            },
          }
        )
        .then((res) => {
          // console.log(res);
          if (res.code == 0) {
            this.$message.success("分配成功");
            this.detailAxios();
          } else {
            this.$message.error(res.message);
          }
        });
    }, 300),
    is_null(content) {
      if (
        content + "" != "" &&
        content + "" != "undefined" &&
        content + "" != "null" &&
        content + "" != "请选择"
      ) {
        return false;
      } else {
        return true;
      }
    },
  },
};
</script>

<style scoped lang="scss">
.div1 {
  margin-left: -16px;
  background: url(../../../assets/breadcrumb2.png);
  width: 120px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  color: #2d7edf;
}

.div2 {
  margin-left: -16px;
  background: url(../../../assets/breadcrumb1.png);
  width: 120px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  color: #fff;
}
.div3 {
  margin-left: -8px;
  background: url(../../../assets/breadcrumb3.png);
  width: 120px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  color: #2d7edf;
}
.header {
  font-size: 16px;
  color: #2d7edf;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}
.address {
  padding: 10px;
  background: #fff;
  .box {
    font-size: 15px;
    color: #333;
    margin-top: 10px;
    border: 1px solid #eee;
    padding: 10px;
    box-shadow: 0 1px 4px 1px #eee;
    p {
      margin-right: 80px;
      line-height: 30px;
    }
    p:nth-child(1),
    p:nth-child(2),
    p:nth-child(3),
    p:nth-child(4) {
      display: inline-block;
    }
  }
}
.order {
  padding: 10px;
  background: #fff;
  margin: 15px 0;
}
.select {
  margin-top: 30px;
  padding-left: 70px;
  span {
    font-size: 15px;
  }
  p {
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
  }
  /deep/ input[type="text"],
  input[type="number"] {
    height: 32px;
    line-height: 32px;
    color: #000;
  }
  /deep/.el-input__icon {
    height: 32px;
    line-height: 32px;
    color: #000;
  }
}
/deep/ .el-input--suffix .el-input__inner {
  background: #fff;
  color: #000;
  width: 110px;
  box-shadow: none;
}
/deep/ .el-button {
  padding: 8px 13px;
}
.select {
  display: inline-block;
  margin-right: 40px;
}
</style>
